!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define("sdsl",["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var L=function(t,i){return(L=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])})(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function e(){this.constructor=t}L(t,i),t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}function a(r,n){var s,o,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:i(0),throw:i(1),return:i(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function i(e){return function(t){var i=[e,t];if(s)throw new TypeError("Generator is already executing.");for(;u;)try{if(s=1,o&&(h=2&i[0]?o.return:i[0]?o.throw||((h=o.return)&&h.call(o),0):o.next)&&!(h=h.call(o,i[1])).done)return h;switch(o=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]<h[3]))u.label=i[1];else if(6===i[0]&&u.label<h[1])u.label=h[1],h=i;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(i)}}i=n.call(r,u)}catch(t){i=[6,t],o=0}finally{s=h=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function c(t){var i="function"==typeof Symbol&&Symbol.iterator,e=i&&t[i],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,i){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,n,s=e.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(r=s.next()).done;)o.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}return o}function h(t,i,e){if(e||2===arguments.length)for(var r,n=0,s=i.length;n<s;n++)!r&&n in i||((r=r||Array.prototype.slice.call(i,0,n))[n]=i[n]);return t.concat(r||Array.prototype.slice.call(i))}function S(t){this.iteratorType=t=void 0===t?0:t}q.prototype.size=function(){return this.t},q.prototype.empty=function(){return 0===this.t};var e=q;function q(){this.t=0}i(z,V=e);var V,r=z;function z(){return null!==V&&V.apply(this,arguments)||this}i(n,I=e),n.prototype.clear=function(){this.t=0,this.i.length=0},n.prototype.push=function(t){this.i.push(t),this.t+=1},n.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},n.prototype.top=function(){return this.i[this.t-1]};var I,M=n;function n(t){void 0===t&&(t=[]);var i=I.call(this)||this;return i.i=[],t.forEach(function(t){return i.push(t)}),i}i(T,C=r);var C,s=T;function T(){return null!==C&&C.apply(this,arguments)||this}i(u,_=S),Object.defineProperty(u.prototype,"pointer",{get:function(){return this.o(this.h)},set:function(t){this.v(this.h,t)},enumerable:!1,configurable:!0}),u.prototype.equals=function(t){return this.h===t.h};var _,K=u;function u(t,i,e,r,n){n=_.call(this,n)||this;return n.h=t,n.u=i,n.o=e,n.v=r,0===n.iteratorType?(n.pre=function(){if(0===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this},n.next=function(){if(this.h===this.u())throw new RangeError("Random Iterator access denied!");return this.h+=1,this}):(n.pre=function(){if(this.h===this.u()-1)throw new RangeError("Random iterator access denied!");return this.h+=1,this},n.next=function(){if(-1===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this}),n}i(D,X=K),D.prototype.copy=function(){return new D(this.h,this.u,this.o,this.v,this.iteratorType)};var X,f=D;function D(){return null!==X&&X.apply(this,arguments)||this}i(p,W=s),p.prototype.I=function(){for(var t=[],i=Math.max(this.O>>1,1),e=0;e<i;++e)t[e]=new Array(this.S);for(e=this.l;e<this.O;++e)t[t.length]=this.k[e];for(e=0;e<this.L;++e)t[t.length]=this.k[e];t[t.length]=h([],o(this.k[this.L]),!1),this.l=i,this.L=t.length-1;for(e=0;e<i;++e)t[t.length]=new Array(this.S);this.k=t,this.O=t.length},p.prototype.g=function(t){var t=this._+t+1,i=t%this.S,e=i-1,t=this.l+(t-i)/this.S;return 0==i&&--t,t%=this.O,e<0&&(e+=this.S),{curNodeBucketIndex:t,curNodePointerIndex:e}},p.prototype.clear=function(){this.k=[[]],this.O=1,this.l=this.L=this.t=0,this._=this.p=this.S>>1},p.prototype.front=function(){return this.k[this.l][this._]},p.prototype.back=function(){return this.k[this.L][this.p]},p.prototype.begin=function(){return new f(0,this.size,this.getElementByPos,this.setElementByPos)},p.prototype.end=function(){return new f(this.t,this.size,this.getElementByPos,this.setElementByPos)},p.prototype.rBegin=function(){return new f(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},p.prototype.rEnd=function(){return new f(-1,this.size,this.getElementByPos,this.setElementByPos,1)},p.prototype.pushBack=function(t){this.t&&(this.p<this.S-1?this.p+=1:(this.L<this.O-1?this.L+=1:this.L=0,this.p=0),this.L===this.l&&this.p===this._&&this.I()),this.t+=1,this.k[this.L][this.p]=t},p.prototype.popBack=function(){this.t&&(this.k[this.L][this.p]=void 0,1!==this.t&&(0<this.p?--this.p:(0<this.L?--this.L:this.L=this.O-1,this.p=this.S-1)),--this.t)},p.prototype.pushFront=function(t){this.t&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.O-1,this._=this.S-1),this.l===this.L&&this._===this.p&&this.I()),this.t+=1,this.k[this.l][this._]=t},p.prototype.popFront=function(){this.t&&(this.k[this.l][this._]=void 0,1!==this.t&&(this._<this.S-1?this._+=1:(this.l<this.O-1?this.l+=1:this.l=0,this._=0)),--this.t)},p.prototype.forEach=function(t){for(var i=0;i<this.t;++i)t(this.getElementByPos(i),i)},p.prototype.getElementByPos=function(t){var t=this.g(t),i=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.k[i][t]},p.prototype.setElementByPos=function(t,i){var t=this.g(t),e=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.k[e][t]=i},p.prototype.insert=function(t,i,e){if(void 0===e&&(e=1),0===t)for(;e--;)this.pushFront(i);else if(t===this.t)for(;e--;)this.pushBack(i);else{for(var r=[],n=t;n<this.t;++n)r.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<e;++n)this.pushBack(i);for(n=0;n<r.length;++n)this.pushBack(r[n])}},p.prototype.cut=function(t){var i,e;t<0?this.clear():(i=(e=this.g(t)).curNodeBucketIndex,e=e.curNodePointerIndex,this.L=i,this.p=e,this.t=t+1)},p.prototype.eraseElementByPos=function(t){var i=this;if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var e=[],r=t+1;r<this.t;++r)e.push(this.getElementByPos(r));this.cut(t),this.popBack(),e.forEach(function(t){return i.pushBack(t)})}},p.prototype.eraseElementByValue=function(t){if(this.t){for(var i=[],e=0;e<this.t;++e){var r=this.getElementByPos(e);r!==t&&i.push(r)}for(var n=i.length,e=0;e<n;++e)this.setElementByPos(e,i[e]);this.cut(n-1)}},p.prototype.eraseElementByIterator=function(t){var i=t.h;return this.eraseElementByPos(i),t=t.next()},p.prototype.find=function(t){for(var i=0;i<this.t;++i)if(this.getElementByPos(i)===t)return new f(i,this.size,this.getElementByPos,this.setElementByPos);return this.end()},p.prototype.reverse=function(){for(var t=0,i=this.t-1;t<i;){var e=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(i)),this.setElementByPos(i,e),t+=1,--i}},p.prototype.unique=function(){if(!(this.t<=1)){for(var t=1,i=this.getElementByPos(0),e=1;e<this.t;++e){var r=this.getElementByPos(e);r!==i&&this.setElementByPos(t++,i=r)}for(;this.t>t;)this.popBack()}},p.prototype.sort=function(t){for(var i=[],e=0;e<this.t;++e)i.push(this.getElementByPos(e));i.sort(t);for(e=0;e<this.t;++e)this.setElementByPos(e,i[e])},p.prototype.shrinkToFit=function(){if(this.t){var i=[];this.forEach(function(t){return i.push(t)}),this.O=Math.max(Math.ceil(this.t/this.S),1),this.t=this.l=this.L=this._=this.p=0,this.k=[];for(var t=0;t<this.O;++t)this.k.push(new Array(this.S));for(t=0;t<i.length;++t)this.pushBack(i[t])}},p.prototype[Symbol.iterator]=function(){return function(){var i;return a(this,function(t){switch(t.label){case 0:i=0,t.label=1;case 1:return i<this.t?[4,this.getElementByPos(i)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++i,[3,1];case 4:return[2]}})}.bind(this)()};var W,Y=p;function p(t,i){void 0===t&&(t=[]),void 0===i&&(i=4096);var e,r=W.call(this)||this;if(r.l=0,r._=0,r.L=0,r.p=0,r.O=0,r.k=[],"size"in t)e="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");e=t.length}r.S=i,r.O=Math.max(Math.ceil(e/r.S),1);for(var n=0;n<r.O;++n)r.k.push(new Array(r.S));i=Math.ceil(e/r.S);return r.l=r.L=(r.O>>1)-(i>>1),r._=r.p=r.S-e%r.S>>1,t.forEach(function(t){return r.pushBack(t)}),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}i(l,Z=e),l.prototype.clear=function(){this.T.clear(),this.t=0},l.prototype.push=function(t){this.T.pushBack(t),this.t+=1},l.prototype.pop=function(){this.T.popFront(),this.t&&--this.t},l.prototype.front=function(){return this.T.front()};var Z,$=l;function l(t){void 0===t&&(t=[]);var i=Z.call(this)||this;return i.T=new Y(t),i.t=i.T.size(),i}i(y,Q=e),y.prototype.m=function(t){for(var i=this.q[t];0<t;){var e=t-1>>1,r=this.q[e];if(this.M(r,i)<=0)break;this.q[t]=r,t=e}this.q[t]=i},y.prototype.D=function(t,i){for(var e=this.q[t];t<i;){var r=t<<1|1,n=r+1,s=this.q[r];if(n<this.t&&0<this.M(s,this.q[n])&&(s=this.q[r=n]),0<=this.M(s,e))break;this.q[t]=s,t=r}this.q[t]=e},y.prototype.clear=function(){this.t=0,this.q.length=0},y.prototype.push=function(t){this.q.push(t),this.m(this.t),this.t+=1},y.prototype.pop=function(){var t;this.t&&(t=this.q.pop(),--this.t,this.t&&(this.q[0]=t,this.D(0,this.t>>1)))},y.prototype.top=function(){return this.q[0]},y.prototype.find=function(t){return 0<=this.q.indexOf(t)},y.prototype.remove=function(t){t=this.q.indexOf(t);return!(t<0)&&(0===t?this.pop():t===this.t-1?(this.q.pop(),--this.t):(this.q.splice(t,1,this.q.pop()),--this.t,this.m(t),this.D(t,this.t>>1)),!0)},y.prototype.updateItem=function(t){t=this.q.indexOf(t);return!(t<0)&&(this.m(t),this.D(t,this.t>>1),!0)},y.prototype.toArray=function(){return h([],o(this.q),!1)};var Q,tt=y;function y(t,i,e){void 0===t&&(t=[]),void 0===i&&(i=function(t,i){return i<t?-1:t<i?1:0}),void 0===e&&(e=!0);for(var r=Q.call(this)||this,n=(r.M=i,Array.isArray(t)?r.q=e?h([],o(t),!1):t:(r.q=[],t.forEach(function(t){return r.q.push(t)})),r.t=r.q.length,r.t>>1),s=r.t-1>>1;0<=s;--s)r.D(s,n);return r}i(et,it=K),et.prototype.copy=function(){return new et(this.h,this.u,this.o,this.v,this.iteratorType)};var it,v=et;function et(){return null!==it&&it.apply(this,arguments)||this}i(w,rt=s),w.prototype.clear=function(){this.t=0,this.C.length=0},w.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},w.prototype.end=function(){return new v(this.t,this.size,this.getElementByPos,this.setElementByPos)},w.prototype.rBegin=function(){return new v(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},w.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},w.prototype.front=function(){return this.C[0]},w.prototype.back=function(){return this.C[this.t-1]},w.prototype.forEach=function(t){for(var i=0;i<this.t;++i)t(this.C[i],i)},w.prototype.getElementByPos=function(t){return this.C[t]},w.prototype.eraseElementByPos=function(t){this.C.splice(t,1),--this.t},w.prototype.eraseElementByValue=function(t){for(var i=0,e=0;e<this.t;++e)this.C[e]!==t&&(this.C[i++]=this.C[e]);this.t=this.C.length=i},w.prototype.eraseElementByIterator=function(t){var i=t.h;return t=t.next(),this.eraseElementByPos(i),t},w.prototype.pushBack=function(t){this.C.push(t),this.t+=1},w.prototype.popBack=function(){this.t&&(this.C.pop(),--this.t)},w.prototype.setElementByPos=function(t,i){this.C[t]=i},w.prototype.insert=function(t,i,e){var r;void 0===e&&(e=1),(r=this.C).splice.apply(r,h([t,0],o(new Array(e).fill(i)),!1)),this.t+=e},w.prototype.find=function(t){for(var i=0;i<this.t;++i)if(this.C[i]===t)return new v(i,this.size,this.getElementByPos,this.getElementByPos);return this.end()},w.prototype.reverse=function(){this.C.reverse()},w.prototype.unique=function(){for(var t=1,i=1;i<this.t;++i)this.C[i]!==this.C[i-1]&&(this.C[t++]=this.C[i]);this.t=this.C.length=t},w.prototype.sort=function(t){this.C.sort(t)},w.prototype[Symbol.iterator]=function(){return function(){return a(this,function(t){switch(t.label){case 0:return[5,c(this.C)];case 1:return[2,t.sent()]}})}.bind(this)()};var rt,d=w;function w(t,i){void 0===t&&(t=[]),void 0===i&&(i=!0);var e=rt.call(this)||this;return Array.isArray(t)?(e.C=i?h([],o(t),!1):t,e.t=t.length):(e.C=[],t.forEach(function(t){return e.pushBack(t)})),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}var nt,B=function(t){this.R=void 0,this.V=void 0,this.H=void 0,this.R=t},E=(i(g,nt=S),Object.defineProperty(g.prototype,"pointer",{get:function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h.R},set:function(t){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");this.h.R=t},enumerable:!1,configurable:!0}),g.prototype.equals=function(t){return this.h===t.h},g.prototype.copy=function(){return new g(this.h,this.N,this.iteratorType)},g);function g(t,i,e){e=nt.call(this,e)||this;return e.h=t,e.N=i,0===e.iteratorType?(e.pre=function(){if(this.h.V===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.V,this},e.next=function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.H,this}):(e.pre=function(){if(this.h.H===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.H,this},e.next=function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.V,this}),e}i(N,st=s),N.prototype.clear=function(){this.t=0,this.j=this.P=void 0,this.N.V=this.N.H=void 0},N.prototype.begin=function(){return new E(this.j||this.N,this.N)},N.prototype.end=function(){return new E(this.N,this.N)},N.prototype.rBegin=function(){return new E(this.P||this.N,this.N,1)},N.prototype.rEnd=function(){return new E(this.N,this.N,1)},N.prototype.front=function(){return this.j?this.j.R:void 0},N.prototype.back=function(){return this.P?this.P.R:void 0},N.prototype.forEach=function(t){if(this.t)for(var i=this.j,e=0;i!==this.N;)t(i.R,e++),i=i.H},N.prototype.getElementByPos=function(t){for(var i=this.j;t--;)i=i.H;return i.R},N.prototype.eraseElementByPos=function(t){if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var i=this.j;t--;)i=i.H;var e=i.V,r=i.H;(r.V=e).H=r,--this.t}},N.prototype.eraseElementByValue=function(t){for(;this.j&&this.j.R===t;)this.popFront();for(;this.P&&this.P.R===t;)this.popBack();if(this.j)for(var i,e,r=this.j;r!==this.N;)r.R===t&&(i=r.V,((e=r.H).V=i).H=e,--this.t),r=r.H},N.prototype.eraseElementByIterator=function(t){var i,e=t.h;if(e===this.N)throw new RangeError("Invalid iterator");return t=t.next(),this.j===e?this.popFront():this.P===e?this.popBack():(i=e.V,((e=e.H).V=i).H=e,--this.t),t},N.prototype.pushBack=function(t){this.t+=1;t=new B(t);this.P?((this.P.H=t).V=this.P,this.P=t):(this.j=this.P=t,this.N.H=this.j,this.j.V=this.N),this.P.H=this.N,this.N.V=this.P},N.prototype.popBack=function(){this.P&&(--this.t,this.j===this.P?(this.j=this.P=void 0,this.N.H=void 0):(this.P=this.P.V,this.P.H=this.N),this.N.V=this.P)},N.prototype.setElementByPos=function(t,i){for(var e=this.j;t--;)e=e.H;e.R=i},N.prototype.insert=function(t,i,e){if(!((e=void 0===e?1:e)<=0))if(0===t)for(;e--;)this.pushFront(i);else if(t===this.t)for(;e--;)this.pushBack(i);else{for(var r=this.j,n=1;n<t;++n)r=r.H;var s=r.H;for(this.t+=e;e--;)r.H=new B(i),r=(r.H.V=r).H;(r.H=s).V=r}},N.prototype.find=function(t){if(this.j)for(var i=this.j;i!==this.N;){if(i.R===t)return new E(i,this.N);i=i.H}return this.end()},N.prototype.reverse=function(){if(!(this.t<=1))for(var t=this.j,i=this.P,e=0;e<<1<this.t;){var r=t.R;t.R=i.R,i.R=r,t=t.H,i=i.V,e+=1}},N.prototype.unique=function(){if(!(this.t<=1))for(var t=this.j;t!==this.N;){for(var i=t;i.H&&i.R===i.H.R;)i=i.H,--this.t;t.H=i.H,t=(t.H.V=t).H}},N.prototype.sort=function(t){var i,e;this.t<=1||(i=[],this.forEach(function(t){return i.push(t)}),i.sort(t),e=this.j,i.forEach(function(t){e.R=t,e=e.H}))},N.prototype.pushFront=function(t){this.t+=1;t=new B(t);this.j?(t.H=this.j,this.j.V=t,this.j=t):(this.j=this.P=t,this.P.H=this.N,this.N.V=this.P),this.N.H=this.j,this.j.V=this.N},N.prototype.popFront=function(){this.j&&(--this.t,this.j===this.P?(this.j=this.P=void 0,this.N.V=this.P):(this.j=this.j.H,this.j.V=this.N),this.N.H=this.j)},N.prototype.merge=function(t){var e,r=this;this.j?(e=this.j,t.forEach(function(t){for(;e&&e!==r.N&&e.R<=t;)e=e.H;var i;e===r.N?(r.pushBack(t),e=r.P):e===r.j?(r.pushFront(t),e=r.j):(r.t+=1,(i=e.V).H=new B(t),((i.H.V=i).H.H=e).V=i.H)})):t.forEach(function(t){return r.pushBack(t)})},N.prototype[Symbol.iterator]=function(){return function(){var i;return a(this,function(t){switch(t.label){case 0:if(!this.j)return[2];i=this.j,t.label=1;case 1:return i===this.N?[3,3]:[4,i.R];case 2:return t.sent(),i=i.H,[3,1];case 3:return[2]}})}.bind(this)()};var st,K=N;function N(t){void 0===t&&(t=[]);var i=st.call(this)||this;return i.N=new B,i.j=void 0,i.P=void 0,t.forEach(function(t){return i.pushBack(t)}),i}m.prototype.pre=function(){var t=this;if(1===t.A&&t.F.F===t)t=t.J;else if(t.G)for(t=t.G;t.J;)t=t.J;else{for(var i=t.F;i.G===t;)i=(t=i).F;t=i}return t},m.prototype.next=function(){var t=this;if(t.J){for(t=t.J;t.G;)t=t.G;return t}for(var i=t.F;i.J===t;)i=(t=i).F;return t.J!==i?i:t},m.prototype.rotateLeft=function(){var t=this.F,i=this.J,e=i.G;return t.F===this?t.F=i:t.G===this?t.G=i:t.J=i,i.F=t,(i.G=this).F=i,(this.J=e)&&(e.F=this),i},m.prototype.rotateRight=function(){var t=this.F,i=this.G,e=i.J;return t.F===this?t.F=i:t.G===this?t.G=i:t.J=i,i.F=t,(i.J=this).F=i,(this.G=e)&&(e.F=this),i};var ot=m;function m(t,i){this.A=1,this.B=void 0,this.R=void 0,this.G=void 0,this.J=void 0,this.F=void 0,this.B=t,this.R=i}i(b,P=ot),b.prototype.rotateLeft=function(){var t=P.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},b.prototype.rotateRight=function(){var t=P.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},b.prototype.recount=function(){this.K=1,this.G&&(this.K+=this.G.K),this.J&&(this.K+=this.J.K)};var P,ht=b;function b(){var t=null!==P&&P.apply(this,arguments)||this;return t.G=void 0,t.J=void 0,t.F=void 0,t.K=1,t}i(G,ut=r),G.prototype.et=function(t,i){for(var e;t;){var r=this.M(t.B,i);if(r<0)t=t.J;else{if(!(0<r))return t;t=(e=t).G}}return void 0===e?this.N:e},G.prototype.rt=function(t,i){for(var e;t;)t=this.M(t.B,i)<=0?t.J:(e=t).G;return void 0===e?this.N:e},G.prototype.nt=function(t,i){for(var e;t;){var r=this.M(t.B,i);if(r<0)t=(e=t).J;else{if(!(0<r))return t;t=t.G}}return void 0===e?this.N:e},G.prototype.st=function(t,i){for(var e;t;)t=this.M(t.B,i)<0?(e=t).J:t.G;return void 0===e?this.N:e},G.prototype.ht=function(t){for(;;){var i,e=t.F;if(e===this.N)return;if(1===t.A)return void(t.A=0);if(t===e.G)if(1===(i=e.J).A)i.A=0,e.A=1,e===this.U?this.U=e.rotateLeft():e.rotateLeft();else{if(i.J&&1===i.J.A)return i.A=e.A,e.A=0,i.J.A=0,void(e===this.U?this.U=e.rotateLeft():e.rotateLeft());i.G&&1===i.G.A?(i.A=1,i.G.A=0,i.rotateRight()):(i.A=1,t=e)}else if(1===(i=e.G).A)i.A=0,e.A=1,e===this.U?this.U=e.rotateRight():e.rotateRight();else{if(i.G&&1===i.G.A)return i.A=e.A,e.A=0,i.G.A=0,void(e===this.U?this.U=e.rotateRight():e.rotateRight());i.J&&1===i.J.A?(i.A=1,i.J.A=0,i.rotateLeft()):(i.A=1,t=e)}}},G.prototype.it=function(t){var i;if(1===this.t)return this.clear(),this.N;for(var e=t;e.G||e.J;){if(e.J)for(e=e.J;e.G;)e=e.G;else e=e.G;i=o([e.B,t.B],2),t.B=i[0],e.B=i[1],i=o([e.R,t.R],2),t.R=i[0],e.R=i[1],t=e}this.N.G===e?this.N.G=e.F:this.N.J===e&&(this.N.J=e.F),this.ht(e);var r=e.F;return e===r.G?r.G=void 0:r.J=void 0,--this.t,this.U.A=0,r},G.prototype.$=function(t){for(;;){var i=t.F;if(0===i.A)return;var e,r,n=i.F;if(i===n.G){if((e=n.J)&&1===e.A){if(e.A=i.A=0,n===this.U)return;n.A=1,t=n;continue}if(t===i.J)return t.A=0,t.G&&(t.G.F=i),t.J&&(t.J.F=n),i.J=t.G,n.G=t.J,t.G=i,(t.J=n)===this.U?(this.U=t,this.N.F=t):(r=n.F).G===n?r.G=t:r.J=t,t.F=n.F,i.F=t,n.F=t,n.A=1,{parentNode:i,grandParent:n,curNode:t};i.A=0,n===this.U?this.U=n.rotateRight():n.rotateRight()}else{if((e=n.G)&&1===e.A){if(e.A=i.A=0,n===this.U)return;n.A=1,t=n;continue}if(t===i.G)return t.A=0,t.G&&(t.G.F=n),t.J&&(t.J.F=i),n.J=t.G,i.G=t.J,t.G=n,t.J=i,n===this.U?(this.U=t,this.N.F=t):(r=n.F).G===n?r.G=t:r.J=t,t.F=n.F,i.F=t,n.F=t,n.A=1,{parentNode:i,grandParent:n,curNode:t};i.A=0,n===this.U?this.U=n.rotateLeft():n.rotateLeft()}return void(n.A=1)}},G.prototype.Z=function(t,i,e){if(void 0===this.U)this.t+=1,this.U=new this.X(t,i),this.U.A=0,this.U.F=this.N,this.N.F=this.U,this.N.G=this.U,this.N.J=this.U;else{var r,n=this.N.G,s=this.M(n.B,t);if(0!==s){if(0<s)n.G=new this.X(t,i),r=(n.G.F=n).G,this.N.G=r;else{var s=this.N.J,o=this.M(s.B,t);if(0===o)return void(s.R=i);if(o<0)s.J=new this.X(t,i),r=(s.J.F=s).J,this.N.J=r;else{if(void 0!==e){o=e.h;if(o!==this.N){s=this.M(o.B,t);if(0===s)return void(o.R=i);if(0<s){e=o.pre(),s=this.M(e.B,t);if(0===s)return void(e.R=i);s<0&&(r=new this.X(t,i),void 0===e.J?(e.J=r).F=e:(o.G=r).F=o)}}}if(void 0===r)for(r=this.U;;){var h=this.M(r.B,t);if(0<h){if(void 0===r.G){r.G=new this.X(t,i),r=(r.G.F=r).G;break}r=r.G}else{if(!(h<0))return void(r.R=i);if(void 0===r.J){r.J=new this.X(t,i),r=(r.J.F=r).J;break}r=r.J}}}}return this.t+=1,r}n.R=i}},G.prototype.clear=function(){this.t=0,this.U=void 0,this.N.F=void 0,this.N.G=this.N.J=void 0},G.prototype.updateKeyByIterator=function(t,i){t=t.h;if(t===this.N)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.N.G)return 0<this.M(t.next().B,i)&&(t.B=i,!0);if(t===this.N.J)return this.M(t.pre().B,i)<0&&(t.B=i,!0);var e=t.pre().B;if(0<=this.M(e,i))return!1;if(e=t.next().B,this.M(e,i)<=0)return!1}return t.B=i,!0},G.prototype.eraseElementByPos=function(i){var e=this,r=0;this.W(this.U,function(t){return i===r?(e.tt(t),!0):(r+=1,!1)})},G.prototype.ut=function(t,i){for(;t;){var e=this.M(t.B,i);if(e<0)t=t.J;else{if(!(0<e))return t;t=t.G}}return t},G.prototype.eraseElementByKey=function(t){!this.t||void 0!==(t=this.ut(this.U,t))&&this.tt(t)},G.prototype.eraseElementByIterator=function(t){var i=t.h;if(i===this.N)throw new RangeError("Invalid iterator");return void 0===i.J&&(t=t.next()),this.tt(i),t},G.prototype.getHeight=function(){var i;return this.t?(i=function(t){return t?Math.max(i(t.G),i(t.J))+1:0})(this.U):0};var ut,s=G;function G(t,i){void 0===t&&(t=function(t,i){return t<i?-1:i<t?1:0}),void 0===i&&(i=!1);var e=ut.call(this)||this;return e.U=void 0,e.W=function(t,i){return void 0!==t&&(!!e.W(t.G,i)||(!!i(t)||e.W(t.J,i)))},e.M=t,i?(e.X=ht,e.Y=function(t,i,e){t=this.Z(t,i,e);if(t){for(var r=t.F;r!==this.N;)r.K+=1,r=r.F;var i=this.$(t);i&&(e=i.parentNode,t=i.grandParent,i=i.curNode,e.recount(),t.recount(),i.recount())}},e.tt=function(t){for(var i=this.it(t);i!==this.N;)--i.K,i=i.F}):(e.X=ot,e.Y=function(t,i,e){t=this.Z(t,i,e);t&&this.$(t)},e.tt=e.it),e.N=new e.X,e}i(at,ft=S),Object.defineProperty(at.prototype,"index",{get:function(){var t=this.h,i=this.N.F;if(t===this.N)return i?i.K-1:0;var e=0;for(t.G&&(e+=t.G.K);t!==i;){var r=t.F;t===r.J&&(e+=1,r.G&&(e+=r.G.K)),t=r}return e},enumerable:!1,configurable:!0}),at.prototype.equals=function(t){return this.h===t.h};var ft,r=at;function at(t,i,e){e=ft.call(this,e)||this;return e.h=t,e.N=i,0===e.iteratorType?(e.pre=function(){if(this.h===this.N.G)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this},e.next=function(){if(this.h===this.N)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this}):(e.pre=function(){if(this.h===this.N.J)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this},e.next=function(){if(this.h===this.N)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this}),e}i(R,ct=r),Object.defineProperty(R.prototype,"pointer",{get:function(){if(this.h===this.N)throw new RangeError("OrderedSet iterator access denied!");return this.h.B},enumerable:!1,configurable:!0}),R.prototype.copy=function(){return new R(this.h,this.N,this.iteratorType)};var ct,J=R;function R(){return null!==ct&&ct.apply(this,arguments)||this}i(F,pt=s),F.prototype.begin=function(){return new J(this.N.G||this.N,this.N)},F.prototype.end=function(){return new J(this.N,this.N)},F.prototype.rBegin=function(){return new J(this.N.J||this.N,this.N,1)},F.prototype.rEnd=function(){return new J(this.N,this.N,1)},F.prototype.front=function(){return this.N.G?this.N.G.B:void 0},F.prototype.back=function(){return this.N.J?this.N.J.B:void 0},F.prototype.forEach=function(t){var i,e,r=0;try{for(var n=c(this),s=n.next();!s.done;s=n.next())t(s.value,r++)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}},F.prototype.getElementByPos=function(t){var i,e,r,n=0;try{for(var s=c(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){r=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return r},F.prototype.insert=function(t,i){this.Y(t,void 0,i)},F.prototype.find=function(t){t=this.ut(this.U,t);return void 0!==t?new J(t,this.N):this.end()},F.prototype.lowerBound=function(t){t=this.et(this.U,t);return new J(t,this.N)},F.prototype.upperBound=function(t){t=this.rt(this.U,t);return new J(t,this.N)},F.prototype.reverseLowerBound=function(t){t=this.nt(this.U,t);return new J(t,this.N)},F.prototype.reverseUpperBound=function(t){t=this.st(this.U,t);return new J(t,this.N)},F.prototype.union=function(t){var i=this;t.forEach(function(t){return i.insert(t)})},F.prototype[Symbol.iterator]=function(){return this.ft(this.U)};var pt,k=F;function F(t,i,e){void 0===t&&(t=[]);var r=pt.call(this,i,e)||this;return r.ft=function(i){return a(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,c(this.ft(i.G))];case 1:return t.sent(),[4,i.B];case 2:return t.sent(),[5,c(this.ft(i.J))];case 3:return t.sent(),[2]}})},t.forEach(function(t){return r.insert(t)}),r}i(O,lt=r),Object.defineProperty(O.prototype,"pointer",{get:function(){var r=this;if(this.h===this.N)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,i){return"0"===i?r.h.B:"1"===i?r.h.R:void 0},set:function(t,i,e){if("1"!==i)throw new TypeError("props must be 1");return r.h.R=e,!0}})},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.h,this.N,this.iteratorType)};var lt,j=O;function O(){return null!==lt&&lt.apply(this,arguments)||this}i(A,yt=s),A.prototype.begin=function(){return new j(this.N.G||this.N,this.N)},A.prototype.end=function(){return new j(this.N,this.N)},A.prototype.rBegin=function(){return new j(this.N.J||this.N,this.N,1)},A.prototype.rEnd=function(){return new j(this.N,this.N,1)},A.prototype.front=function(){var t;if(this.t)return[(t=this.N.G).B,t.R]},A.prototype.back=function(){var t;if(this.t)return[(t=this.N.J).B,t.R]},A.prototype.forEach=function(t){var i,e,r=0;try{for(var n=c(this),s=n.next();!s.done;s=n.next())t(s.value,r++)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}},A.prototype.lowerBound=function(t){t=this.et(this.U,t);return new j(t,this.N)},A.prototype.upperBound=function(t){t=this.rt(this.U,t);return new j(t,this.N)},A.prototype.reverseLowerBound=function(t){t=this.nt(this.U,t);return new j(t,this.N)},A.prototype.reverseUpperBound=function(t){t=this.st(this.U,t);return new j(t,this.N)},A.prototype.setElement=function(t,i,e){this.Y(t,i,e)},A.prototype.find=function(t){t=this.ut(this.U,t);return void 0!==t?new j(t,this.N):this.end()},A.prototype.getElementByKey=function(t){t=this.ut(this.U,t);return t?t.R:void 0},A.prototype.getElementByPos=function(t){var i,e,r,n=0;try{for(var s=c(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){r=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return r},A.prototype.union=function(t){var e=this;t.forEach(function(t){var t=o(t,2),i=t[0],t=t[1];return e.setElement(i,t)})},A.prototype[Symbol.iterator]=function(){return this.ft(this.U)};var yt,x=A;function A(t,i,e){void 0===t&&(t=[]);var r=yt.call(this,i,e)||this;return r.ft=function(i){return a(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,c(this.ft(i.G))];case 1:return t.sent(),[4,[i.B,i.R]];case 2:return t.sent(),[5,c(this.ft(i.J))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=o(t,2),i=t[0],t=t[1];return r.setElement(i,t)}),r}i(dt,vt=e),dt.prototype.clear=function(){this.t=0,this.O=this.ot,this.vt=[]};var vt,r=dt;function dt(t,i){void 0===t&&(t=16),void 0===i&&(i=function(t){for(var i="string"!=typeof t?JSON.stringify(t):t,e=0,r=i.length,n=0;n<r;n++){e=(e<<5)-e+i.charCodeAt(n);e|=0}return e>>>0});var e=vt.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return e.O=e.ot=t,e.ct=i,e}i(H,wt=r),H.prototype.I=function(){var s=this;if(!(1073741824<=this.O)){for(var o=[],h=this.O,u=(this.O<<=1,Object.keys(this.vt)),t=u.length,f=this,i=0;i<t;++i)!function(t){var i,e,t=parseInt(u[t]),r=f.vt[t],n=r.size();0===n||(1===n?(n=r.front(),o[f.ct(n)&f.O-1]=new d([n],!1)):(i=[],e=[],r.forEach(function(t){(0==(s.ct(t)&h)?i:e).push(t)}),r instanceof k?(o[t]=6<i.length?new k(i):new d(i,!1),o[t+h]=6<e.length?new k(e):new d(e,!1)):(o[t]=new d(i,!1),o[t+h]=new d(e,!1))))}(i);this.vt=o}},H.prototype.forEach=function(i){for(var t=Object.values(this.vt),e=t.length,r=0,n=0;n<e;++n)t[n].forEach(function(t){return i(t,r++)})},H.prototype.insert=function(t){var i=this.ct(t)&this.O-1,e=this.vt[i];if(e){var r=e.size();if(e instanceof d){if(!e.find(t).equals(e.end()))return;if(e.pushBack(t),8<=r+1){if(this.O<=64)return this.t+=1,void this.I();this.vt[i]=new k(e)}this.t+=1}else{e.insert(t);e=e.size();this.t+=e-r}}else this.vt[i]=new d([t],!1),this.t+=1;this.t>.75*this.O&&this.I()},H.prototype.eraseElementByKey=function(t){var i,e,r=this.ct(t)&this.O-1,n=this.vt[r];!n||0!==(i=n.size())&&(n instanceof d?(n.eraseElementByValue(t),e=n.size(),this.t+=e-i):(n.eraseElementByKey(t),e=n.size(),this.t+=e-i,e<=6&&(this.vt[r]=new d(n))))},H.prototype.find=function(t){var i=this.ct(t)&this.O-1,i=this.vt[i];return!!i&&!i.find(t).equals(i.end())},H.prototype[Symbol.iterator]=function(){return function(){var i,e,r,n,s,o,h,u,f;return a(this,function(t){switch(t.label){case 0:i=Object.values(this.vt),e=i.length,r=0,t.label=1;case 1:if(!(r<e))return[3,10];n=i[r],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,s=c(n),o=s.next(),t.label=3;case 3:return o.done?[3,6]:[4,o.value];case 4:t.sent(),t.label=5;case 5:return o=s.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{o&&!o.done&&(f=s.return)&&f.call(s)}finally{if(u)throw u.error}return[7];case 9:return++r,[3,1];case 10:return[2]}})}.bind(this)()};var wt,s=H;function H(t,i,e){void 0===t&&(t=[]);var r=wt.call(this,i,e)||this;return r.vt=[],t.forEach(function(t){return r.insert(t)}),r}i(U,Bt=r),U.prototype.I=function(){var s=this;if(!(1073741824<=this.O)){for(var o=[],h=this.O,u=(this.O<<=1,Object.keys(this.vt)),t=u.length,f=this,i=0;i<t;++i)!function(t){var i,e,t=parseInt(u[t]),r=f.vt[t],n=r.size();0===n||(1===n?(n=r.front(),o[f.ct(n[0])&f.O-1]=new d([n],!1)):(i=[],e=[],r.forEach(function(t){(0==(s.ct(t[0])&h)?i:e).push(t)}),r instanceof x?(o[t]=6<i.length?new x(i):new d(i,!1),o[t+h]=6<e.length?new x(e):new d(e,!1)):(o[t]=new d(i,!1),o[t+h]=new d(e,!1))))}(i);this.vt=o}},U.prototype.forEach=function(i){for(var t=Object.values(this.vt),e=t.length,r=0,n=0;n<e;++n)t[n].forEach(function(t){return i(t,r++)})},U.prototype.setElement=function(t,i){var e,r=this.ct(t)&this.O-1,n=this.vt[r];if(n){var s=n.size();if(n instanceof d){try{for(var o=c(n),h=o.next();!h.done;h=o.next()){var u=h.value;if(u[0]===t)return void(u[1]=i)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(f=o.return)&&f.call(o)}finally{if(e)throw e.error}}if(n.pushBack([t,i]),8<=s+1){if(this.O<=64)return this.t+=1,void this.I();this.vt[r]=new x(this.vt[r])}this.t+=1}else{n.setElement(t,i);var f=n.size();this.t+=f-s}}else this.t+=1,this.vt[r]=new d([[t,i]],!1);this.t>.75*this.O&&this.I()},U.prototype.getElementByKey=function(t){var i,e,r=this.ct(t)&this.O-1,r=this.vt[r];if(r){if(r instanceof x)return r.getElementByKey(t);try{for(var n=c(r),s=n.next();!s.done;s=n.next()){var o=s.value;if(o[0]===t)return o[1]}}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}}},U.prototype.eraseElementByKey=function(t){var i=this.ct(t)&this.O-1,e=this.vt[i];if(e)if(e instanceof d){var r=0;try{for(var n=c(e),s=n.next();!s.done;s=n.next()){if(s.value[0]===t)return e.eraseElementByPos(r),void--this.t;r+=1}}catch(t){h={error:t}}finally{try{s&&!s.done&&(o=n.return)&&o.call(n)}finally{if(h)throw h.error}}}else{var o=e.size(),h=(e.eraseElementByKey(t),e.size());this.t+=h-o,h<=6&&(this.vt[i]=new d(e))}},U.prototype.find=function(t){var i,e,r=this.ct(t)&this.O-1,r=this.vt[r];if(r){if(r instanceof x)return!r.find(t).equals(r.end());try{for(var n=c(r),s=n.next();!s.done;s=n.next())if(s.value[0]===t)return!0}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}}return!1},U.prototype[Symbol.iterator]=function(){return function(){var i,e,r,n,s,o,h,u,f;return a(this,function(t){switch(t.label){case 0:i=Object.values(this.vt),e=i.length,r=0,t.label=1;case 1:if(!(r<e))return[3,10];n=i[r],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,s=c(n),o=s.next(),t.label=3;case 3:return o.done?[3,6]:[4,o.value];case 4:t.sent(),t.label=5;case 5:return o=s.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{o&&!o.done&&(f=s.return)&&f.call(s)}finally{if(u)throw u.error}return[7];case 9:return++r,[3,1];case 10:return[2]}})}.bind(this)()};var Bt,e=U;function U(t,i,e){void 0===t&&(t=[]);var r=Bt.call(this,i,e)||this;return r.vt=[],t.forEach(function(t){return r.setElement(t[0],t[1])}),r}t.Deque=Y,t.HashMap=e,t.HashSet=s,t.LinkList=K,t.OrderedMap=x,t.OrderedSet=k,t.PriorityQueue=tt,t.Queue=$,t.Stack=M,t.Vector=d,Object.defineProperty(t,"dt",{value:!0})});
//# sourceMappingURL=js-sdsl.min.js.map
